<template>
  <el-form ref="addForm" :model="addForm" label-width="120px">
    <el-form-item label="充值金额">
      <el-input
        type="input"
        v-model="addForm.rechargeMoney"
        size="small"
        placeholder="请输入充值金额"
        ><template slot="append">元</template></el-input
      >
    </el-form-item>
    <el-form-item label="赠送金额">
      <el-input
        type="input"
        v-model="addForm.sendMoney"
        size="small"
        placeholder="请输入赠送金额"
        ><template slot="append">元</template></el-input
      >
    </el-form-item>
    <el-form-item label="返现金额">
      <el-input
        type="input"
        v-model="addForm.returnMoney"
        size="small"
        placeholder="请输入返现金额"
        ><template slot="append">元</template></el-input
      >
    </el-form-item>
    <el-form-item label="推广员奖励金额">
      <el-input
        type="input"
        v-model="addForm.shareMoney"
        size="small"
        placeholder="请输入推广员奖励金额"
        ><template slot="append">元</template></el-input
      >
    </el-form-item>
    <div class="c-red">
      注：
      <br />1、赠送金额为个人账户余额，仅用于扫码加注支付
      <br />2、返现金额为微信红包零钱，打款至充值微信零钱包
      <br />3、赠送金额和返现金额，终端客户在充值时只可选择其中一种
    </div>
    <div class="dividing-line m-t-20 m-b-20"></div>
    <div class="flex-end">
      <el-button type="primary" size="small" plain @click="back"
        >取消</el-button
      >
      <el-button
        type="primary"
        size="small"
        @click="confirmAdd"
        :loading="saveLoading"
        >确定</el-button
      >
    </div>
  </el-form>
</template>
<script>
import { save } from "@/api/marketing-management/preferntial-top-up-management";
import { msgSuccess } from "@/util/common-util";

export default {
  data() {
    return {
      addForm: {},
      saveLoading: false,
    };
  },
  methods: {
    machineChange(v) {
      this.addForm.machineId = v.id;
    },
    confirmAdd() {
      this.saveLoading = true;
      save(this.addForm).then((res) => {
        msgSuccess("添加成功");
        this.saveLoading = false;
        this.$emit("closeAddDialog", "refresh");
      });
    },
    back() {
      this.$emit("closeAddDialog", "cancel");
    },
  },
};
</script>
